package com.example.mydefinedview1.ui

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View

/**
 *
 * @Author： LJH
 * @Time： 2022/6/29
 * @description：
 */
class CircleView(context: Context, attr:AttributeSet?):View(context,attr) {
    private val paint = Paint()
    init {
        paint.isAntiAlias = true
    }
    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        //练习内容：使用 canvas.drawCircle() 方法画圆
        //一共四个圆：1.实心圆 2.空心圆 3.蓝色实心圆 4.线宽为 20 的空心圆
        canvas?.drawCircle(200F,150F,100F,paint)
        paint.style = Paint.Style.STROKE
        canvas?.drawCircle(450F,150F,100F,paint)
        paint.style = Paint.Style.FILL
        paint.color = Color.parseColor("#4A90E2")
        canvas?.drawCircle(200F,400F,100F,paint)
        paint.style = Paint.Style.STROKE
        paint.color = Color.BLACK
        paint.strokeWidth = 40F
        canvas?.drawCircle(450F,400F,100F,paint)
    }
}